﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using ConsolidationTool.WebParts.ControlTemplates;
using ConsolidationTool.WebParts.ControlTemplates.FS.Template;
using ConsolidationTool.Common;

namespace ConsolidationTool.WebParts.Budget_Input.BudgetWebpart.BudgetCommonEdit
{
    public partial class BudgetCommonEditUserControl : FSUserControlBase
    {
        public string BillFormDataFieldID { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            (commonButtomAction as CommonButtomAction).SaveButtonClicked += new CommonButtomAction.SaveButtonClickHandler(ESNewFormUserControl_SaveButtonClicked);
            TopSelector = commonEntitySelector as CommonEntitySelector; ButtomAction = commonButtomAction as CommonButtomAction;
            ControlMode = Title.ControlMode;
            (koScriptPart as KoScriptPart).ListTitle = Title.List.Title;
            (koCommonTemplate as KoCommonTemplate).ListTitle = Title.List.Title;
            BillFormDataFieldID = BillFromData.ClientID;
            if (isBudgetMode)
            {
                TopSelector.monthTextBox.Text = "";
                //  TopSelector.yearTextBox.Text = Common.BusinessService.GetConfiguration(Constants.Budget_Input_Year);
                TopSelector.monthTextBox.Visible = false;
            }
        }

        protected override void OnPreRender(EventArgs e)
        {
            if (!IsPostBack)
                base.FormInitialization();
            base.OnPreRender(e);
        }

        public override SPListItem Item
        {
            get
            {
                return ConsolidationTool_CoName.ListItem;
            }
        }

        void ESNewFormUserControl_SaveButtonClicked(object sender, EventArgs e)
        {
            base.Save();
        }
    }
}